﻿using System;
using System.Threading;

namespace IU.Admin.Tabs
{
    public partial class CrearEmpresa : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        public void Process_OnClick(object sender, EventArgs e)
        {
            string redirect = "CrearEmpresaOK.htm";

            try
            {
                ModuloSoporte.AdministradoraUsuarios.CrearEmpresa(
                    // Page 1: Empresa
                    TextBoxRazon.Text,
                    TextBoxMail.Text,
                    TextBoxCuit.Text,
                    HiddenSituacionIVA.Value,

                    // Page 2: Admin
                    TextBoxAdminName.Text,
                    TextBoxAdminPass.Text,
                    TextBoxAdminMail.Text,
                    
                    // Page 3: Sucursal
                    TextBoxSucName.Text,
                    CheckCasaCentral.Checked,
                    HiddenFieldProvincia.Value,
                    TextBoxLocalidad.Text,
                    TextBoxDir.Text,
                    HiddenFieldDirNumber.Value,
                    HiddenFieldDirPiso.Value,
                    HiddenFieldCP.Value,
                    TextBoxTel.Text,
                    TextBoxFax.Text,
                    HiddenFieldFacturacion.Value,

                    // Page 4: Período
                    DateTime.Parse(HiddenFieldDateStart.Value),
                    DateTime.Parse(HiddenFieldDateEnd.Value)
                );
            }
            catch (Exception ex)
            {
                UIHelper.SetMessage("Error", ex.Message);
                redirect = "~/Mensaje.aspx";
            }
            finally
            {
                Response.Redirect(redirect);
            }
        }
    }
}
